package com.example.obs.vo;

import lombok.Data;

/**
 * 返回结果视图
 * @author Kevin
 * @Date 2020-01-21 14:51
 */
@Data
public class ResultVO {

    Integer status;

    String msg;

    Object data;

    private ResultVO() {
    }

    public static ResultVO success(String msg, Object data) {
        ResultVO resultVO = new ResultVO();
        resultVO.status = 0;
        resultVO.msg = msg;
        resultVO.data = data;
        return resultVO;
    }

    public static ResultVO success() {
        return success(null, null);
    }

    public static ResultVO success(Object data) {
        return success(null, data);
    }

    public static ResultVO error(String s) {
        ResultVO resultVO = new ResultVO();
        resultVO.status = -1;
        resultVO.msg = s;
        return resultVO;
    }

    public static ResultVO error(Integer status, String s) {
        ResultVO resultVO = new ResultVO();
        resultVO.status = status;
        resultVO.msg = s;
        return resultVO;
    }
}
